import router from '@system.router';

export default {
    data: {

        icon:{
            iconOne:'common/icon/fitness-outline.png',
            iconTwo:'common/icon/flame-outline.png',
            iconThree:'common/icon/person-outline.png',
            iconOneSelected:'common/icon/fitness.png',
            iconTwoSelected:'common/icon/flame.png',
            iconThreeSelected:'common/icon/person.png',
            iconOneUnSelected:'common/icon/fitness-outline.png',
            iconTwoUnSelected:'common/icon/flame-outline.png',
            iconThreeUnSelected:'common/icon/person-outline.png',
        },
        analysisMenu:[
            {
                id:1,
                image:'common/icon/list.png',
                title:'今日目标',
                value:'未完成',
            },
            {
                id:2,
                image:'common/icon/running-man.png',
                title:'运动量',
                value:'8365步',
            },
            {
                id:3,
                image:'common/icon/food.png',
                title:'摄入热量',
                value:'300千卡',
            }

        ],

        image:{
            swiperImage1:'common/image/swiperImage1.png',
            swiperImage2:'common/image/swiperImage2.png',
            swiperImage3:'common/image/swiperImage3.png',
        },
        person:{
            iconHead:'common/icon/ZGMF-X20A.jpg',
            username:'Kira',
            ID:'ZGMF-X20A',
        },
        menu:[
            {
                ID:1,
                title:'个人信息',
                img:'common/icon/star-red.png',
            },
            {
                ID:2,
                title:'运动记录',
                img:'common/icon/star-blue.png',
            },
            {
                ID:3,
                title:'设备管理',
                img:'common/icon/star-yellow.png',
            },
        ],
        rightEnter: 'common/icon/right-enter.png',

        scale: 1.0,
        cRadius: 125, //圆环半径
        cRate: 0,  //圆环绘制进度
        lineWidth: 10, //圆环宽度
        cColor: '#FBDB32',  //进度颜色，当只有一个颜色值时为纯色进度
        bgColorIn: '#F5FFFA',     //进度条圆环背景颜色

//        oRange: 60,
        circleState: null,
        render : null,

    },

    onShow(){
        this.icon.iconOne = this.icon.iconOneSelected;
    },

    menuClick(click){
        if(click.currentTarget.attr.value === 1){
            router.push({
                uri:'pages/person_data/person_data',
            });
        }else if(click.currentTarget.attr.value === 2){
            router.push({
                uri:'pages/exercise_history/exercise_history',
            });
        }else if(click.currentTarget.attr.value === 3){
            router.push({
                uri:'pages/device_manage/device_manage',
            });
        }
    },
    setRate(){
        this.cRate =0;
        this.cRate =80;
    },
    paintComplete(e) {
        if(e.detail.state = 'Completed') {
            console.log('circleState: '+this.circleState);
            if(!(this.circleState == 'afterAnimation')) {
                this.playAnimation();
            };
        }
    },
    playAnimation() {
        let frame = [
            {
                transform: {
                    scale: 1,
                    translateY: '0px',
                }
            },
            {
                transform: {
                    scale: 0.8,
                    translateY: '-240px',
                }
            }
        ];
        let option = {
            easing: 'ease-in',
            duration: 1000,
            fill: 'forwards',
            iterations: 1,
        };
        let animation = this.$element('circle').animate(frame,option);
        animation.play();
        this.circleState = 'afterAnimation';
        setTimeout(()=>{
            this.render = 'finish';
            this.changeCircle();
        },1000)

    },
    changeCircle() {
        this.scale=0.8;
    },
    startRun(){
        router.push({
            uri:'pages/run/run',
        });
    },
    showPerson(){

    }
}
